package com.lb.statck.mapper.shopcart;

import com.lb.statck.pojo.dto.OrderDTO;
import com.lb.statck.pojo.dto.ShopDto;
import com.lb.statck.pojo.vo.OrderVo;
import com.lb.statck.pojo.vo.ShopCartVO;
import org.apache.ibatis.annotations.*;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface ShopcartMapper {
    @Insert("INSERT INTO shopcart (userid,product_code,num) values (#{userId},#{productCode},#{number})")
    void insert(ShopDto shopDto);
    @Select("select s.*,p.name,p.price,p.imageurl from products p inner join  shopcart s on  s.product_code=p.product_code ")
    List<ShopCartVO> get();
    @Delete("delete from shopcart where userid=#{userId}")
    void deleteShop(String userId);
   @Select("select count(id) from shopcart where product_code=#{productCode}")
    int selectOne(ShopDto shopDto);
    @Update("UPDATE shopcart SET num = #{number} WHERE product_code = #{productCode}")
    void update(ShopDto shopDto);
    @Select("select num from  shopcart  WHERE product_code = #{productCode}")
    int getNumber(ShopDto shopDto);
    @Select("select * from shopcart WHERE userid = #{userId}")
    List<ShopCartVO> ListShopCart(ShopDto shopDto);
    @Select("select price from products where product_code=#{productCode}")
    BigDecimal getPrice(OrderDTO shopDto);
}
